package com.boulderai.mcp.model;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonNode;

/**
 * MCP协议错误信息
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
public class McpError {
    
    @JsonProperty("code")
    private int code;
    
    @JsonProperty("message")
    private String message;
    
    @JsonProperty("data")
    private JsonNode data;
    
    public McpError() {}
    
    public McpError(int code, String message) {
        this.code = code;
        this.message = message;
    }
    
    public McpError(int code, String message, JsonNode data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }
    
    // 常见错误代码
    public static final int PARSE_ERROR = -32700;
    public static final int INVALID_REQUEST = -32600;
    public static final int METHOD_NOT_FOUND = -32601;
    public static final int INVALID_PARAMS = -32602;
    public static final int INTERNAL_ERROR = -32603;
    
    // MCP特定错误代码
    public static final int RESOURCE_NOT_FOUND = -32001;
    public static final int TOOL_NOT_FOUND = -32002;
    public static final int PERMISSION_DENIED = -32003;
    
    // Getters and Setters
    public int getCode() {
        return code;
    }
    
    public void setCode(int code) {
        this.code = code;
    }
    
    public String getMessage() {
        return message;
    }
    
    public void setMessage(String message) {
        this.message = message;
    }
    
    public JsonNode getData() {
        return data;
    }
    
    public void setData(JsonNode data) {
        this.data = data;
    }
    
    @Override
    public String toString() {
        return String.format("McpError{code=%d, message='%s', data=%s}", 
                           code, message, data);
    }
}